// 用户相关类型
export interface User {
  id: number
  username: string
  email: string
  realName: string
  role: string
  avatar: string
  phone?: string
  department?: string
  status: string
  lastLoginAt: Date | null
  loginCount: number
  createdAt: Date
  remark?: string
}

// 用户表单类型
export interface UserForm {
  id?: number
  username: string
  email: string
  realName: string
  phone: string
  role: string
  department: string
  status: string
  password: string
  remark: string
}

// 项目相关类型
export interface Project {
  id: number
  name: string
  description?: string
  status: 'PLANNING' | 'IN_PROGRESS' | 'COMPLETED' | 'CANCELLED'
  startDate?: string
  endDate?: string
  managerId: number
  manager?: User
  createdAt: string
  updatedAt: string
}

// 任务相关类型
export interface Task {
  id: number
  title: string
  description?: string
  status: 'PENDING' | 'IN_PROGRESS' | 'COMPLETED' | 'CANCELLED'
  priority: 'LOW' | 'MEDIUM' | 'HIGH'
  projectId: number
  project?: Project
  assigneeId?: number
  assignee?: User
  creatorId: number
  creator?: User
  startDate?: string
  endDate?: string
  estimatedHours?: number
  actualHours?: number
  createdAt: string
  updatedAt: string
}

// 问题相关类型
export interface Issue {
  id: number
  title: string
  description?: string
  type: 'BUG' | 'FEATURE' | 'IMPROVEMENT' | 'TASK'
  status: 'OPEN' | 'IN_PROGRESS' | 'RESOLVED' | 'CLOSED'
  priority: 'LOW' | 'MEDIUM' | 'HIGH'
  projectId: number
  project?: Project
  reporterId: number
  reporter?: User
  assigneeId?: number
  assignee?: User
  resolvedAt?: string
  createdAt: string
  updatedAt: string
}

// 日报相关类型
export interface DailyReport {
  id: number
  userId: number
  user?: User
  projectId: number
  project?: Project
  reportDate: string
  workContent: string
  workHours: number
  nextPlan?: string
  issues?: string
  createdAt: string
  updatedAt: string
}

// API请求相关类型
export interface LoginRequest {
  username: string
  password: string
}

export interface RegisterRequest {
  username: string
  email: string
  password: string
  realName: string
}

export interface LoginResponse {
  token: string
  user: User
}

export interface ApiResponse<T = any> {
  code: number
  message: string
  data: T
}

// 分页相关类型
export interface PageRequest {
  page: number
  size: number
  sort?: string
  direction?: 'ASC' | 'DESC'
}

export interface PageResponse<T> {
  content: T[]
  totalElements: number
  totalPages: number
  size: number
  number: number
  first: boolean
  last: boolean
}

// 统计相关类型
export interface WorkTimeStats {
  totalHours: number
  averageHours: number
  workDays: number
  period: string
}

export interface ProjectStats {
  totalProjects: number
  completedProjects: number
  inProgressProjects: number
  completionRate: number
}

export interface TaskStats {
  totalTasks: number
  completedTasks: number
  inProgressTasks: number
  pendingTasks: number
  completionRate: number
}

export interface IssueStats {
  totalIssues: number
  openIssues: number
  resolvedIssues: number
  closedIssues: number
  resolutionRate: number
}

export interface DashboardStats {
  projectStats: ProjectStats
  taskStats: TaskStats
  issueStats: IssueStats
  workTimeStats: WorkTimeStats
}

// 表单相关类型
export interface FormRule {
  required?: boolean
  message?: string
  trigger?: string | string[]
  min?: number
  max?: number
  pattern?: RegExp
  validator?: (rule: any, value: any, callback: any) => void
}

export interface FormRules {
  [key: string]: FormRule[]
}

// 表格相关类型
export interface TableColumn {
  prop: string
  label: string
  width?: string | number
  minWidth?: string | number
  fixed?: boolean | 'left' | 'right'
  sortable?: boolean
  formatter?: (row: any, column: any, cellValue: any, index: number) => string
}

// 菜单相关类型
export interface MenuItem {
  id: string
  title: string
  icon?: string
  path?: string
  children?: MenuItem[]
  meta?: {
    requiresAuth?: boolean
    requiresAdmin?: boolean
    hidden?: boolean
  }
}

// 通知相关类型
export interface Notification {
  id: number
  title: string
  content: string
  type: 'info' | 'success' | 'warning' | 'error'
  read: boolean
  userId: number
  createdAt: string
}

// 文件上传相关类型
export interface UploadFile {
  id: string
  name: string
  size: number
  type: string
  url?: string
  status: 'ready' | 'uploading' | 'success' | 'error'
  progress?: number
}

// 搜索相关类型
export interface SearchParams {
  keyword?: string
  status?: string
  priority?: string
  projectId?: number
  assigneeId?: number
  startDate?: string
  endDate?: string
}

// 导出相关类型
export interface ExportParams {
  format: 'excel' | 'pdf' | 'csv'
  dateRange?: [string, string]
  filters?: Record<string, any>
}